* (bug 8310) Blank line added to top of 'post' when page is blank
authorRob Church <robchurch@users.mediawiki.org>
Mon, 18 Dec 2006 19:30:26 +0000 (19:30 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 18 Dec 2006 19:30:26 +0000 (19:30 +0000)
RELEASE-NOTES
includes/Article.php

index 7fe83fd..e19b27e 100644 (file)
@@ -344,6 +344,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 2785) Accept optional colon prefix in links when formatting comments
 * Don't show "you can view and copy the source of this page" message for
   pages which don't exist
+* (bug 8310) Blank line added to top of 'post' when page is blank
 
 == Languages updated ==
 
index 1e2a9a6..0ebd440 100644 (file)
@@ -1134,13 +1134,18 @@ class Article {
                        }
                        $oldtext = $rev->getText();
 
-                       if($section=='new') {
-                               if($summary) $subject="== {$summary} ==\n\n";
-                               $text=$oldtext."\n\n".$subject.$text;
+                       if( $section == 'new' ) {
+                               # Inserting a new section
+                               $subject = $summary ? "== {$summary} ==\n\n" : '';
+                               $text = strlen( trim( $oldtext ) ) > 0
+                                               ? "{$oldtext}\n\n{$subject}{$text}"
+                                               : "{$oldtext}{$subject}{$text}";
                        } else {
+                               # Replacing an existing section; roll out the big guns
                                global $wgParser;
                                $text = $wgParser->replaceSection( $oldtext, $section, $text );
                        }
+
                }
 
                wfProfileOut( __METHOD__ );